
var loginToken = null;

(function($, owner) {

	//添加地址
	 owner.create_address = function(address) {
	 	owner.get_local_state();
		var url = ADDRESS_API + '/create.do';
		address.loginToken = loginToken;
		return requestService.httpPost(url, address);
	}

	//查询地址
	owner.find_address = function(id) {
		owner.get_local_state();
		var url = ADDRESS_API + '/find.do';
		var parms = {
			loginToken: loginToken,
			id: id
		};
		return requestService.httpGet(url,parms);
	}

	//删除地址
	owner.delete_address = function(id) {
		owner.get_local_state();
		var url = ADDRESS_API + '/delete.do';
		var parms = {
			loginToken: loginToken,
			id: id
		};
		return requestService.httpGet(url,parms);
	}

	//查询我的地址列表
	owner.my_address_list = function() {
		var url = ADDRESS_API + '/findAddressList.do';
		owner.get_local_state();
		var parms = {
			loginToken: loginToken
		};
		return requestService.httpGet(url,parms);
	}
	
	owner.update_address =function(address){
		owner.get_local_state();
		var url = ADDRESS_API +'/update.do';
		address.loginToken = loginToken;
		return requestService.httpPost(url,address);
	}
	
	owner.get_local_state = function() {
		var state = JSON.parse(localStorage.getItem('$state'));
		if(state != null) {
			loginToken = state.loginToken;
		}
	}

}(mui, window.addressService = {}));